﻿#pragma once

#include <QtWidgets/QMainWindow>
#include <QVTKOpenGLNativeWidget.h>
#include <pcl/point_types.h> 
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/cloud_viewer.h>
#include <tuple>

class PCLFit : public QMainWindow
{
	Q_OBJECT

public:
	PCLFit(QWidget* parent = nullptr);
	~PCLFit();

private:
	pcl::visualization::PCLVisualizer::Ptr viewer;
	pcl::PointCloud<pcl::PointXYZ>::Ptr planeCloud;

	pcl::PointCloud<pcl::PointXYZ>::Ptr cylinderCloud;
	
	QVTKOpenGLNativeWidget* vtkWidget;

	std::tuple<double, double, double, double>
		FitPlane(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);

	// 拟合圆柱体
	// 轴线点坐标，轴线法向量，半径
	std::tuple<pcl::PointXYZ, pcl::PointXYZ,
		double, pcl::PointCloud<pcl::PointXYZ>::Ptr>
		FitCylinder(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
};
